package com.songlanyun.modules.pointconfig.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.songlanyun.modules.pointconfig.model.dto.PointConfigDto;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.songlanyun.modules.pointconfig.entity.PointConfig;
import com.songlanyun.modules.pointconfig.service.PointConfigService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;



/**
 * 积分配置
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2022-09-21 14:18:02
 */
@RestController
@RequestMapping("admin/pointconfig")
public class PointConfigController extends AbstractController {
    @Autowired
    private PointConfigService pointConfigService;


    /**
     * 信息
     */
    @GetMapping("/info")
    //@RequiresPermissions("pointconfig:pointconfig:info")
    public R load(){
		PointConfig pointConfig = pointConfigService.loadConfig(false);

        return R.ok().put("data", pointConfig);
    }

    /**
     * 保存
     */
    @PostMapping("/set")
    //@RequiresPermissions("pointconfig:pointconfig:save")
    public R save(@RequestBody PointConfigDto pointConfig){
        pointConfig.setAdminUsername(this.getUser().getUsername());
		pointConfigService.set(pointConfig);
        return R.ok();
    }




}
